home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / game / role / ldmud-3.2-bin.lha / mud / doc / LPC / arrays < prev    next >
Text File  |  2001-04-06  |  1KB  |  33 lines

  1. CONCEPT
  2.         arrays
  3.  
  4. DESCRIPTION
  5.         There is support for arrays. The arrays can't be declared, but
  6.         be should allocated dynamically with the function 'allocate()'
  7.         (see efun/allocate).
  8.  
  9.         Arrays are stored by reference, so all assignments of whole
  10.         arrays will just copy the address. The array will be
  11.         deallocated when no variable points to it any longer.
  12.  
  13.         When a variable points to an array, items can be accessed with
  14.         indexing: 'arr[3]' as an example. The name of the array being
  15.         indexed can be any expression, even a function call:
  16.         'func()[2]'. It can also be another array, if this array has
  17.         pointers to arrays:
  18.  
  19.         arr = allocate(2);
  20.         arr[0] = allocate(3);
  21.         arr[1] = allocate(3);
  22.  
  23.         Now 'arr[1][2]' is a valid value.
  24.  
  25.         The 'sizeof()' function (in true C, not a function) will give
  26.         the number of elements in an array (see efun/sizeof).
  27.  
  28. NOTE
  29.         Nowadays it is most of the time preferable to use an array
  30.         constructor, a list surrounded by '({' and '})',
  31.         e.g. ({ 1, "xx", 2 }) will be construct a new array with
  32.         size 3, initialized with 1, "xx" and 2 respectively.
  33.